package com.onlinelearn.userservice.controller;

import com.onlinelearn.userservice.dto.UserDTO;
import com.onlinelearn.userservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/users")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/{userId}")
    public ResponseEntity<UserDTO> getUserProfile(@PathVariable Long userId) {
        UserDTO userDTO = userService.getUserById(userId);
        return ResponseEntity.ok(userDTO);
    }

    @PutMapping("/{userId}")
    public ResponseEntity<Void> updateUserProfile(
        @PathVariable Long userId, 
        @RequestBody UserDTO userDTO
    ) {
        userService.updateUserProfile(userId, userDTO);
        return ResponseEntity.ok().build();
    }
} 